package java69.work722.CarManager;

public class Car extends Automobile {
    private String type;//型号

    public Car() {
    }

    public Car(String num, String brand, double rent, boolean store, String type) {
        super(num, brand, rent, store);
        this.type = type;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    static Car[] cars = new Car[]{
            new Car("京NY28588","宝马",800,true,"X6"),
            new Car("京CNY3284","宝马",600,true,"550i"),
            new Car("京NT37465","别克",300,true,"林荫大道"),
            new Car("京NT96968","别克",600,true,"GL8"),
    };
    @Override
    public void sum(String num, int days) {
        double sum;
        boolean pd = false;
        for (int i = 0; i <cars.length ; i++) {
            if (cars[i].getNum().equals(num)){
                pd = true;
                if(days>150){
                    sum = cars[i].getRent() * days * 0.7;
                }else  if(days>30){
                    sum = cars[i].getRent() * days * 0.8;
                }else if(days>7){
                    sum = cars[i].getRent() * days * 0.9;
                }else {
                    sum = cars[i].getRent() * days;
                }
                System.out.println("欢迎租借车牌号："+cars[i].getNum()+",日租金为："+cars[i].getRent()+"元,在库状态为"
                        +cars[i].isStore()+"的车辆："+cars[i].getBrand()+cars[i].getType()+",共"
                        +days+"天，总计须缴费："+sum+"元。");
                break;
            }
        }
        if (pd) {
            System.out.println("租车成功！");
        }else {
            System.out.println("车牌号为"+num+"的轿车不存在！");
        }
    }

}
